<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>角色管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	function page(n,s){
		if(n) $("#pageNo").val(n);
		if(s) $("#pageSize").val(s);
		$("#searchForm").attr("action","${ctx}/sys/role/list");
		$("#searchForm").submit();
    	return false;
    }
	
	function delFunc(id){
		var param="id="+id;
		$.ajax({
			url:"${ctx}/sys/role/roleUserdByUser?"+param,
			success:function(result){
				if(result>0){
					showTip("该角色下存在用户，不能删除！",'',3000,0);
					return;
				}else{
					confirmx('确认要删除该角色吗？','${ctx}/sys/role/delete?'+param);
				}
			}
		});
	}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/role/">角色列表</a></li>
		<shiro:hasPermission name="sys:role:edit"><li><a href="${ctx}/sys/role/form">角色添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="user" action="${ctx}/sys/role/list" method="post" class="breadcrumb form-search ">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
	</form:form>
	<div style="display:none;">
		<sys:message content="${message}" />
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<tr>
			<th>序号</th>
			<th>角色名称</th>
			<th>是否业务员</th>
			<th>角色描述</th><!-- <th>数据范围</th> -->
			<shiro:hasPermission name="sys:role:edit"><th>操作</th></shiro:hasPermission>
		</tr>
		<c:forEach items="${page.list}" var="role" varStatus="stats">
			<tr>
				<td>${stats.index+1}</td>
				<td>${role.name}</td>
				<td>
					<c:choose>
						<c:when test="${role.isSale == 1}">
       						是
    					</c:when>
						<c:otherwise>
        					否
   					 	</c:otherwise>
					</c:choose>
				</td>
				<td>${role.remarks}</td>
				<%-- <td>${fns:getDictLabel(role.dataScope, 'sys_data_scope', '无')}</td> --%>
				<shiro:hasPermission name="sys:role:edit"><td>
					<%-- <a href="${ctx}/sys/role/assign?id=${role.id}">分配</a> --%>
					<c:if test="${(role.sysData eq fns:getDictValue('是', 'yes_no', '1') && fns:getUser().admin)||!(role.sysData eq fns:getDictValue('是', 'yes_no', '1'))}">
						<a href="${ctx}/sys/role/form?id=${role.id}">修改</a>
					</c:if>
					<a href="javascript:;" onclick="delFunc('${role.id}')">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>